package com.xilihui.xlh.business.widget;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.xilihui.xlh.R;
import com.xilihui.xlh.core.util.ToastUtil;
import com.xilihui.xlh.core.util.YEventBuses;

/**
 * Created by Administrator on 2018/5/18.
 */

public class WithdrawPopWindow extends PopupWindow implements View.OnClickListener {
    
    public static final String WITHDRAW = "jifeng";
    
    private View view;
    private TextView tv_all;
    private TextView tv_shz;
    private TextView tv_shtg;
    private TextView tv_shjj;
    private TextView tv_yff;
    
    
    public WithdrawPopWindow(Activity context){

        view = LayoutInflater.from(context).inflate(R.layout.popup_withdraw,null);
        initView();
        this.setContentView(view);
        this.setWidth(LayoutParams.WRAP_CONTENT);
        this.setHeight(LayoutParams.WRAP_CONTENT);
        this.setFocusable(true);
        this.setOutsideTouchable(true);
        this.setAnimationStyle(R.style.AnimationPreview);
        
    }
    
    public void initView(){
        
        tv_all = (TextView)view.findViewById(R.id.tv_qb);
        tv_shz = (TextView)view.findViewById(R.id.tv_shz);
        tv_shtg = (TextView)view.findViewById(R.id.tv_shtg);
        tv_shjj = (TextView)view.findViewById(R.id.tv_shjj);
        tv_yff = (TextView)view.findViewById(R.id.tv_yff); 
        
        tv_all.setOnClickListener(this);
        tv_shz.setOnClickListener(this);
        tv_shtg.setOnClickListener(this);
        tv_shjj.setOnClickListener(this);
        tv_yff.setOnClickListener(this);
        
    }
    
    public void show(View view){
        if(view!=null){
            showAsDropDown(view,0,-20);
        }
    }


    @Override
    public void onClick(View view) {
        dismiss();
        switch (view.getId()){
            case R.id.tv_qb:
                ToastUtil.toastShortPositive("全部");
                YEventBuses.post(new YEventBuses.Event(WITHDRAW).setParams("10086"));
                break;
            case R.id.tv_shz:
                ToastUtil.toastShortPositive("审核中");
                YEventBuses.post(new YEventBuses.Event(WITHDRAW).setParams("0"));
                break;
            case R.id.tv_shtg:
                ToastUtil.toastShortPositive("审核通过");
                YEventBuses.post(new YEventBuses.Event(WITHDRAW).setParams("1"));
                break;
            case R.id.tv_shjj:
                ToastUtil.toastShortPositive("审核拒绝");
                YEventBuses.post(new YEventBuses.Event(WITHDRAW).setParams("-1"));
                break;
            case R.id.tv_yff:
                ToastUtil.toastShortPositive("已发放");
                YEventBuses.post(new YEventBuses.Event(WITHDRAW).setParams("2"));
                break;
        }
    }
    
    
}
